﻿using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Zinnia.Extensions;

namespace Zinnia.WebDemoTest.Controllers
{
    public class RequestController : Controller
    {
        // GET: Request
        [HttpPost]
        public ActionResult Post(string name, string age)
        {
            var parmStr = $"name:{name},age:{age}";
            return Content(parmStr + Encoding.UTF8.GetString(Request.InputStream.ReadBytes()));
        }
        [HttpPost]
        public async Task<ActionResult> AsyncPost(string name, string age)
        {
            var parmStr = await GetParmStr(name, age);
            return Content(parmStr + Encoding.UTF8.GetString(Request.InputStream.ReadBytes()));
        }

        private Task<string> GetParmStr(string name, string age)
        {
            return Task.Run(() => $"name:{name},age:{age}");
        }
    }
}